<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="../js/vue.js"></script>
    </head>
    <body>
        <div id="container">
            名称:<input type="text" v-model.lazy="name" /><br>
            年龄:<input type="number" v-model.number="age" /><br>
            用户名:<input type="text" v-model.trim="username" /><br>
            <input type="button" value="保存" @click="save" />
        </div>
        <script>
           new Vue({
               el:"#container",
               watch:{
                   name:function(val){
                       console.log("val>>>",val)
                   }
               },
               data:{
                   name:"",
                   age:20,
                   username:""
               },
               methods:{
                   save:function(){
                      // console.log(typeof this.age)
                      //this.username.trim()
                      if(this.username=="admin"){
                          console.log("正确")
                      }else{
                          console.log("错误")
                      }
                   }
               }
           });
        </script>
    </body>
</html>
